//
//  def_multiplicative_expression.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_multiplicative_expression_h
#define compilation_def_multiplicative_expression_h

/*
 multiplicative_expression
 : unary_expression {printf("multiplicative_expression unary expression\n");}
 | multiplicative_expression '*' unary_expression {printf("multiplicative_expression mult_expr * unary_expression\n");}
 | multiplicative_expression '|' unary_expression {printf("multiplicative_expression\n");}
 ;
 */

struct def_multiplicative_expression{
	void * parent;
	int type;
	struct def_unary_expression * unary_expression;
	struct def_multiplicative_expression * multiplicative_expression;
};

struct def_multiplicative_expression * multiplicative_expression_create(void * parent){
	struct def_multiplicative_expression * d = malloc(sizeof(*d));
	d->type = 0;
	d->parent = parent;
	return d;
}

void multiplicative_expression_print(struct def_multiplicative_expression * d){
	switch(d->type){
		case 2:
			multiplicative_expression_print(d->multiplicative_expression);
			printf("*");
			unary_expression_print(d->unary_expression);
			break;
		case 3:
			multiplicative_expression_print(d->multiplicative_expression);
			printf("|");
			unary_expression_print(d->unary_expression);
			break;
		case 1:
			unary_expression_print(d->unary_expression);
			break;
	}
}
#endif
